package org.dydl.model.system;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by Jack on 2018/1/30.
 */
@Entity
@Table(name = "materials_purchase")
public class MaterialsPurchase {
    private int id;
    private String uuid;
    private String purchaseSingleNo;
    private String supplier;
    private String createBy;
    private Timestamp createDate;
    private Integer status;
    private Timestamp orderDeliveryDate;
    private Integer totalQuantity;
    private Integer amount;

    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "UUID")
    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    @Basic
    @Column(name = "PURCHASE_SINGLE_NO")
    public String getPurchaseSingleNo() {
        return purchaseSingleNo;
    }

    public void setPurchaseSingleNo(String purchaseSingleNo) {
        this.purchaseSingleNo = purchaseSingleNo;
    }

    @Basic
    @Column(name = "SUPPLIER")
    public String getSupplier() {
        return supplier;
    }

    public void setSupplier(String supplier) {
        this.supplier = supplier;
    }

    @Basic
    @Column(name = "CREATE_BY")
    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    @Basic
    @Column(name = "CREATE_DATE")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    public Timestamp getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Timestamp createDate) {
        this.createDate = createDate;
    }

    @Basic
    @Column(name = "STATUS")
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Basic
    @Column(name = "ORDER_DELIVERY_DATE")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    public Timestamp getOrderDeliveryDate() {
        return orderDeliveryDate;
    }

    public void setOrderDeliveryDate(Timestamp orderDeliveryDate) {
        this.orderDeliveryDate = orderDeliveryDate;
    }

    @Basic
    @Column(name = "TOTAL_QUANTITY")
    public Integer getTotalQuantity() {
        return totalQuantity;
    }

    public void setTotalQuantity(Integer totalQuantity) {
        this.totalQuantity = totalQuantity;
    }

    @Basic
    @Column(name = "AMOUNT")
    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MaterialsPurchase that = (MaterialsPurchase) o;

        if (id != that.id) return false;
        if (uuid != null ? !uuid.equals(that.uuid) : that.uuid != null) return false;
        if (purchaseSingleNo != null ? !purchaseSingleNo.equals(that.purchaseSingleNo) : that.purchaseSingleNo != null)
            return false;
        if (supplier != null ? !supplier.equals(that.supplier) : that.supplier != null) return false;
        if (createBy != null ? !createBy.equals(that.createBy) : that.createBy != null) return false;
        if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false;
        if (status != null ? !status.equals(that.status) : that.status != null) return false;
        if (orderDeliveryDate != null ? !orderDeliveryDate.equals(that.orderDeliveryDate) : that.orderDeliveryDate != null)
            return false;
        if (totalQuantity != null ? !totalQuantity.equals(that.totalQuantity) : that.totalQuantity != null)
            return false;
        if (amount != null ? !amount.equals(that.amount) : that.amount != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (uuid != null ? uuid.hashCode() : 0);
        result = 31 * result + (purchaseSingleNo != null ? purchaseSingleNo.hashCode() : 0);
        result = 31 * result + (supplier != null ? supplier.hashCode() : 0);
        result = 31 * result + (createBy != null ? createBy.hashCode() : 0);
        result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (orderDeliveryDate != null ? orderDeliveryDate.hashCode() : 0);
        result = 31 * result + (totalQuantity != null ? totalQuantity.hashCode() : 0);
        result = 31 * result + (amount != null ? amount.hashCode() : 0);
        return result;
    }
}
